﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace DataInterpolator.Model
{
   [XmlType("Tops")]
   public class Well_Tops
   {
      public Well_Tops()
      {
         Formations = new List<Well_Formation>();
      }

      public List<Well_Formation> Formations
      {
         get; set;
      }

      public Well_Formation this[string title]
      {
         get
         {
            int idx = Formations.FindIndex((w) =>
            {
               return w.Name == title;
            });

            if (idx < 0)
               throw new KeyNotFoundException();

            return Formations[idx];
         }
      }

      public bool Contains(string title)
      {
         int count = Formations.Count((w) =>
         {
            return w.Name == title;
         });

         return count > 0;
      }
   }
}
